-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): validate yarn.lock in 'start' and 'build' commands and add 'deduplicate' command #668
Conversation
|
||
const duplicates = listDuplicates(deduped) | ||
if (duplicates.size > 0) { | ||
reporter.error('Failed to deduplicate the following packages:') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failing to deduplicate with fixDuplicates
may occur if there are multiple major versions of a dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one. Tested locally in a few apps and works for me.
cli/src/commands/deduplicate.js
Outdated
` * ${chalk.bold(name)} (found versions ${versions.join(', ')})` | ||
) | ||
} | ||
process.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use exit(code, message)
from cli-helpers-engine
for consistency.
# [8.2.0](v8.1.2...v8.2.0) (2021-10-07) ### Features * **cli:** validate yarn.lock in 'start' and 'build' commands and add 'deduplicate' command ([#668](#668)) ([8a8aa4d](8a8aa4d))
🎉 This PR is included in version 8.2.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Looks really awesome @mediremi , nice work! One comment - this will de duplicate in yarn.lock but not in node_modules which requires another |
Closes https://jira.dhis2.org/browse/LIBS-213
yarn.lock
instart
andbuild
commands (warning instart
but error inbuild
) by ensuring that there is only one version of@dhis2/app-runtime
,@dhis2/d2-i18n
,@dhis2/ui
,react
andstyled-jsx
deduplicate
command (which runs yarn-deduplicate)Implementation notes
i18next
as a sensitive singleton dependency,i18next-scanner
declares the version of itsi18next
dependency as"*"
. This results in two different major versions ofi18next
(@dhis2/d2-i18n
depends on^10.3
, but latest major version is 21), whichyarn-deduplicate
does not attempt to fix. Therefore, addingi18next
would result inyarn build
failing for all app-platform apps unlessyarn.lock
s are manually edited.yarn-deduplicate
's code is included in this PR directly instead of being added as an npm dependency due to modifications required forlistDuplicates
andgetDuplicatedPackages
to work for our use case.